package com.gifcpp.play;

import android.graphics.Bitmap;
import android.util.Log;

public class GifHandler {

    static {
        System.loadLibrary("native-lib");
    }

    public String mTextString = "123123";

    //指针地址
    private static long mNativeGifHandler;


    public static GifHandler load(String path) {
        mNativeGifHandler = loadGif(path);
        GifHandler handler = new GifHandler(mNativeGifHandler);
        return handler;
    }

    //开始加载Gif文件
    //Java+包名+类名+方法名，中间用下划线分割
    //第一个参数 JNIEnv
    //第二个参数 如果是static就是class，如果不是static就是object
    //第三个参数 是需要传递的
    public static native long loadGif(String path);

    public static native int getWidth(long gifHandler);

    public static native int getHeight(long gifHandler);

    public static native int updateFrame(long gifHandler, Bitmap bitmap);

    private GifHandler(long gifHandler) {
        mNativeGifHandler = gifHandler;
    }


    public int getWidth() {
        return getWidth(mNativeGifHandler);
    }

    public int getHeight() {
        return getHeight(mNativeGifHandler);
    }

    public int updateFrame(Bitmap bitmap) {
        return updateFrame(mNativeGifHandler, bitmap);
    }


    public native void hight();

    public native void low();

    public static native void create();

    public static native void destory();

    public native void debug();


    public void callback(int a) {
        Log.i("223223", "lllll:" + a);
    }
}
